/**
 * @fileOverview Main module of the bot
 */

var tlr = {};

(function($) {
	tlr.Bot = function() {
		var active = true,
			debug = false,
			justStarted = true,
			log = [],
			mode = 'battle',
			lastMode;
		
		return {
			/**
			 * Start bot
			 * Triggers "bot-start" event
			 */
			start : function() {
				active = true;
				justStarted = true;
				$(this).trigger('bot-start');

				justStarted = false;
				
				return this;
			},
			
			/**
			 * Stop bot
			 * Triggers "bot-stop" event
			 */
			stop : function() {
				active = false;
				$(this).trigger('bot-stop');
				
				return this;
			},
			
			/**
			 * Toggle bot state
			 */
			toggle : function() {
				active ? this.stop() : this.start();
				
				return this;
			},
		
			debug : function() {
				var args = Array.prototype.slice.call(arguments);
				
				args.unshift(new Date);
				
				debug && console.log.apply(console, args);
				
				return this;
			}
		}
	}
})(jQuery);
